package com.xianggu.mybatis.mapper;

import java.util.Map;

public class SqlParameterReplacer {
    /**
     * 替换 #{param}
     * @param sql
     * @param parameters
     * @return
     */
    public static String replaceParameters(String sql, Map<String, Object> parameters) {
        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
            String placeholder = "#{" + entry.getKey() + "}";
            sql = sql.replace(placeholder, entry.getValue().toString());
        }
        return sql;
    }
}